#include "FrontendState.h"
#include "CharacterIdle.h"

FrontendState::FrontendState(GameContext& gc)
	:GameState(gc)
{
}

FrontendState::~FrontendState(void)
{
}

void FrontendState::Load()
{
	mFont.Load(20);
	mCursor.Load("clickbutton.png");

	mStartButton1.Load("yellowbuttom_off.png", "easybluebuttom_on.png");
	mStartButton1.SetPosition(SVector2(350.0f, 350.0f));
	mStartButton1.SetText("Easy Stage", 255, 0, 0);

	mStartButton2.Load("yellowbuttom_off.png", "diffcultButton_on.png");
	mStartButton2.SetPosition(SVector2(350.0f, 450.0f));
	mStartButton2.SetText("Diffcult Stage", 255, 0, 0);

	mQuitButton.Load("yellowbuttom_off.png", "quitgreenButton_on.png");
	mQuitButton.SetPosition(SVector2(350.0f, 550.0f));
	mQuitButton.SetText("Quit", 255, 0, 0);

	background.Load("BackgroundCucco.jpg");
	backgroundSound.Load("Backgroundsound.mp3");
	backgroundSound.Play(true);
}

void FrontendState::Unload()
{
	mFont.Unload();
	mCursor.Unload();
	mStartButton1.Unload();
	mStartButton2.Unload();
	mQuitButton.Unload();
	background.Unload();
	backgroundSound.Unload();
}

NextState FrontendState::Update(float deltaTime)
{
	mCursor.Update(deltaTime);
	mStartButton1.Update(deltaTime);
	mStartButton2.Update(deltaTime);
	mQuitButton.Update(deltaTime);

	NextState nextState = None;

	if(mStartButton1.IsPressed())
	{
		mGameContext.SetLevel(1);
		nextState = Gameplay;
	}
	else if(mStartButton2.IsPressed())
	{
		mGameContext.SetLevel(2);
		nextState = Gameplay;
	}
	else if(mQuitButton.IsPressed())
	{
		nextState = Quit;
	}
	return nextState;
}

void FrontendState::Render()
{
	background.Render();
	/*mFont.Print("Welcome to the chicken coupe", 200, 250);*/
	mStartButton1.Render();
	mStartButton2.Render();
	mQuitButton.Render();
	mCursor.Render();
}